<?php 
require('common.inc.php');
getsessiontime();
header("Content-type:application/vnd.ms-excel"); 
header("Content-Disposition:filename=test.xls"); 
$username=checkstr($_GET['username']);
$time1=$_GET['time1'];
$time2=$_GET['time2'];
$static=$_GET['static'];
$filter="where xf_type=1 ";
if (trim($username)!="") $filter.=" and uname='".trim($username)."'";
if (trim($time1)!="") $filter.=" and give_help_time>='".strtotime($time1)."'";
if (trim($time2)!="") $filter.=" and give_help_time<='".(strtotime($time2)+3600*24)."'";
if($static==1) $filter.=" and is_fa=0";
if($static==2)   $filter.=" and is_fa=1";
$db->query("select *,ld_give_help.id as aid from ld_give_help left join ld_address on uid=adid  $filter order by give_help_time desc");
$list=$db->rs;
if(!$list){
	return;
}
echo "订单编号\t";echo "用户名\t";echo "查看详情\t";echo "收货人\t";echo "电话\t";echo "地址\t";echo "状态\t";echo "购买时间\t\n";
foreach ($list as $key => $v) {
	if($v['is_fa']==0){
	     $status='未发货</font>';
    }else{
		$status='已发货';
    }
		$help_no = get_help_no('give',$v['uname'],$v['give_help_no']);

	echo $help_no."\t"; 
	echo $v["uname"]."\t";
	if(!empty($v['good_ids'])&&!empty($v['good_nums'])){
		$ids=explode(",",$v['good_ids']);
		$good_nums=explode(",",$v['good_nums']);
		$goodsinfo='';
		foreach ($ids as $key => $vv) {
			if($vv==''){
				continue;
			}
			$db->query("select * from ld_product where id=".$vv,2);
			$good=$db->rs;
			if(!$good){
				continue;
			}
			$goodsinfo=$goodsinfo.$good['productname']." 数量：".$good_nums[$key]." ";
		}
	}
	echo $goodsinfo."\t";
	echo $v["addressname"]."\t";
	echo $v["phone"]."\t";
	echo $v["address"]."\t";
	echo $status."\t";
	echo date("Y-m-d H:i",$v["give_help_time"])."\t\n";
}

?> 